home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / boot / czesc_2 / smsrc / sm / arexx.pas next >
Pascal/Delphi Source File  |  1995-07-11  |  1KB  |  43 lines

  1. Procedure SendARexxCommand;
  2.  
  3. VAR
  4.     rxmsg         : pRexxMsg;
  5.     ap, dummyport : pMsgPort;
  6.     dummsg        : pMessage;
  7.     dp            : string;
  8.     
  9. Begin
  10.     dp := destport + #0;
  11.     if (RexxSysBase <> NIL) and (command <> '') and (destport <> '') then begin
  12.         { rexx available, command and port reasonably valid }
  13.         dummyport := CreateMsgPort;
  14.         if dummyport <> NIL then begin
  15.             { create an ARexx message }
  16.             rxmsg := CreateRexxMsg(DummyPort,NIL,NIL);
  17.             if rxmsg <> NIL then begin
  18.                 { create an argument string }
  19.                 rxmsg^.rm_Args[0] := CreateArgstring(@command[1],length(command));
  20.                 if rxmsg^.rm_Args[0] <> NIL then begin
  21.                     rxmsg^.rm_Action := RXCOMM|RXFF_NOIO;
  22.                     { make sure port does not disapear }
  23.                     Forbid;
  24.                     { find the destination port }
  25.                     ap := FindPort(@dp[1]);
  26.                     if ap <> NIL then
  27.                         { send the message }
  28.                         PutMsg(ap, pMessage(rxmsg));
  29.                     Permit;
  30.                     if ap <> NIL then begin
  31.                         { wait for message and remove }
  32.                         dummsg := WaitPort(DummyPort);
  33.                         dummsg := GetMsg(DummyPort);
  34.                     end;
  35.                     ClearRexxMsg(rxmsg,1);
  36.                 end;
  37.                 DeleteRexxMsg(rxmsg);
  38.             end;
  39.             DeleteMsgPort(dummyport);
  40.         end;
  41.     end;
  42. end;
  43.